package com.cs2.volunteerpostbackend.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@MapperScan("com.cs2.volunteerpostbackend.dao") // 引导系统为数据库接口自动产生实现类，会自动放到spring容器中
public class MyBatisPlusConfig {
    // 系统中发现有mybatis的拦截器，就会自己使用这个拦截器
    // PaginationInnerInterceptor 这个应该就是控制分页的
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.H2));
        return interceptor;
    }
}
